Real

Local Variable Declaration Statement

Syntax samples

REAL <name1>{= <expression1>, <name2>= <expression2>...)

REAL Var1

REAL Counter = 0

REAL Var1 = CLOCK(SEC), Random_Num = RAND(10)

Description

Creates a local variable of type real. Local variables work much the same as attributes, except that they only are available within the logic that declares them. A local variable will be created for each entity that encounters a REAL statement. Local variables are not directly available to subroutines, which have their own local variables. However, a local variable may be passed to a subroutine as a parameter. Local variables are available to macros.

Valid In

Any logic. Variables declared with REAL are valid in any expression within the logic where a real number is valid.

Components

<names>

An identifier for the first local variable. This identifier must be a valid name.

<expressions>

The variable will initially be assigned this value. This expression is evaluated every time the REAL statement is encountered.

Example

The example below uses a local real variable to track the total time an entity waits for another entity to be joined to it. A shipping area has an operation where invoices are joined to boxes to produce packages. The user wants to know exactly how long an invoice must wait before a box arrives to be joined. By setting the value of a local variable, Start, to the clock time just before the JOIN statement and using a LOG statement immediately after the JOIN, we can determine how long each invoice had to wait before a box arrived. A local variable is a better choice here than an entity attribute because the only place the information is needed is inside this logic.

Process Table

Entity

Location

Operation (min)

Box

Packing

WAIT N(10,3)

Invoice

Shipping

REAL Start = CLOCK()

JOIN 1 Box

LOG "Delay:", Start

Routing Table

Blk

Output

Destination

Rule

Move Logic

1

Box

Shipping

JOIN 1

MOVE FOR 1

1

Package

Dock

FIRST 1

MOVE FOR 3

See Also

INT. See Variables.